﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LookZhanji : EventManager {
    public Button SeeZhuang, SeeRet;
    public RawImage mvp, Tuhao, yu;
    public Text mvpName, tuhaoName, yuName;
    public Text dateTime,roomid,peopleNumber;
    public Text times, Difen, shouShu, dairu,AllScore;
    public GameObject zhangjiList, ZhuangList;
    public Text ChageText, ChageText1;
    public RectTransform Need, Need1;
    void Start () {
        AddListenerToButton(SeeZhuang, ShowZhuangList);
        AddListenerToButton(SeeRet, CloseZhuangList);
        //todo:sunfei  
        DownloadHeadTexture(mvp.gameObject.GetComponent<RawImage>(), SaveDate.GetInstance().Roomlist.HMVP);
        DownloadHeadTexture(Tuhao.gameObject.GetComponent<RawImage>(), SaveDate.GetInstance().Roomlist.HTH);
        DownloadHeadTexture(yu.gameObject.GetComponent<RawImage>(), SaveDate.GetInstance().Roomlist.HDY);
    }
    void ShowZhuangList() {
        BindingSource[0].SetActive(true);
    }
    void CloseZhuangList()
    {
        BindingSource[0].SetActive(false);
    }
    public override void InformationSetting()
    {
        if (SaveDate.GetInstance().Roomlist.Who != 0)
        {
            if (SaveDate.GetInstance().Roomlist.IsCreaet)
            {
                ChageText.text = "   俱乐部昵称          战绩              抢庄              ";
            }
            else
            {
                ChageText1.text = "        昵称            手数            带入            战绩 ";
            }
            SetText(AllScore, SaveDate.GetInstance().Roomlist.score.ToString());
            if (SaveDate.GetInstance().Roomlist.ZhuangList != null && SaveDate.GetInstance().Roomlist.ZhuangList.Count > 0)
            {
                ZhuangList.transform.GetComponentsInChildren<OneP.InfinityScrollView.InfinityScrollView>()[0].Setup(SaveDate.GetInstance().Roomlist.ZhuangList.Count);
            }
        }
        else
        {
            if (!SaveDate.GetInstance().Roomlist.IsCreaet)
            {
                ChageText1.text = "        昵称            手数            带入            战绩 ";
            }
            BindingSource[0].SetActive(false);
            Need.sizeDelta = new Vector2(1080, 826);
            BindingSource[3].transform.localPosition = new Vector3(-4.5f, 80, 0);
            BindingSource[4].transform.localPosition = new Vector3(-3, -468, 0);
        }
        SetText(dateTime, SaveDate.GetInstance().Roomlist.date + " " + SaveDate.GetInstance().Roomlist.time);
        SetText(roomid, SaveDate.GetInstance().Roomlist.roomid);
        SetText(times, SaveDate.GetInstance().Roomlist.Times);
        SetText(Difen, SaveDate.GetInstance().Roomlist.Difen);
        SetText(shouShu, SaveDate.GetInstance().Roomlist.AllShouShu);
        SetText(dairu, SaveDate.GetInstance().Roomlist.ALLDaiRu);
        SetText(mvpName, SaveDate.GetInstance().Roomlist.MVP);
        SetText(tuhaoName, SaveDate.GetInstance().Roomlist.TH);
        SetText(yuName, SaveDate.GetInstance().Roomlist.YU);
        if (SaveDate.GetInstance().Roomlist.RoomMsg != null && SaveDate.GetInstance().Roomlist.RoomMsg.Count > 0)
        {
            zhangjiList.transform.GetComponentsInChildren<OneP.InfinityScrollView.InfinityScrollView>()[0].Setup(SaveDate.GetInstance().Roomlist.RoomMsg.Count);
        }
    }
    public void Close()
    {
        Destroy(this.gameObject);
    }
}
